/**
 * AbstractImageFilter.java
 * 
 * @date: 2012-02-09
 * @author: Xiaoyu Guo (MUN# 200982155)
 * This file is part of the course project for COMP 6752, 
 * Application of Computer Graphics. All the file is written
 * by myself.
 */
package mun.cs6752.project.filter.abstractClasses;

import java.awt.image.BufferedImage;

import mun.cs6752.project.filter.interfaces.IImageFilter;
import mun.cs6752.project.filter.interfaces.IImageProvider;
import mun.cs6752.project.ui.ImageCanvas;

/**
 * @author Xiaoyu Guo
 *
 */
public abstract class AbstractImageFilter implements IImageFilter {

    protected IImageProvider provider;
    private String name;
    
    /** Constructor
     * @param provider
     * @param name
     */
    public AbstractImageFilter(IImageProvider provider, String name){
        this.provider = provider;
        this.name = name;
    }
    
    /* (non-Javadoc)
     * @see mun.cs6752.project.filter.interfaces.IImageFilter#getName()
     */
    @Override
    public String getName() {
        return name;
    }
    
    /* (non-Javadoc)
     * @see mun.cs6752.project.filter.interfaces.IImageFilter#isOverridingSourceImageControl()
     */
    @Override
    public boolean isOverridingSourceImageControl(){
        return false;
    }
    
    /* (non-Javadoc)
     * @see mun.cs6752.project.filter.interfaces.IImageFilter#isOverridingTargetImageControl()
     */
    @Override
    public boolean isOverridingTargetImageControl(){
        return false;
    }
    
    /* (non-Javadoc)
     * @see mun.cs6752.project.filter.interfaces.IImageFilter#getSourceImageControl(java.awt.image.BufferedImage)
     */
    @Override
    public ImageCanvas getSourceImageControl(BufferedImage srcImage){
        return null;
    }

    /* (non-Javadoc)
     * @see mun.cs6752.project.filter.interfaces.IImageFilter#getTargetImageControl()
     */
    @Override
    public ImageCanvas getTargetImageControl(){
        return null;
    }
    
    /* Image Manipulation functions */
    
    /** Extract Red from integer RGB color */
    protected int getR(int RGB){
        return (RGB & 0x00FF0000) >> 16;
    }
    
    /** Extract Green from integer RGB color */
    protected int getG(int RGB){
        return (RGB & 0x0000FF00) >> 8;
    }
    
    /** Extract Blue from integer RGB color */
    protected int getB(int RGB){
        return (RGB & 0x000000FF);
    }
    
    /** Construct integer RGB value from separate colors  */
    protected int getRGB(int r, int g, int b){
        return ((r & 0x000000FF) << 16) | ((g & 0x000000FF) << 8) | (b & 0x000000FF);
    }
}
